let Koa = require('koa');

let app = new Koa();

let static = require("koa-static");

let fs = require('fs');

let path = require('path');

app.use(static(process.cwd())) //处理静态资源的目录 

//中间件  async 函数  

//ctx 请求体  响应体

app.use(async (ctx,next) => {
    console.log(ctx.path);  //请求的路径
    let url = path.join(process.cwd(),ctx.path); //完成请求路径
    console.log(url)
    if(fs.existsSync(url)){
        //存在
        let list = fs.readdirSync(url);
        console.log(list);
    }else{
        //不存在
        console.log("当前路径不存在")
    }
})



module.exports = app;